#define _CRT_SECURE_NO_DEPRECATE
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
FILE *fp;
unsigned char c;
unsigned int characters = 0, words = 0, sentences = 0;//字符数，单词数，句子数
bool input_m(const char *name) {
	if ((fp = fopen(name, "rb")) != NULL) { //r rb
		while ((c = fgetc(fp)) != EOF) {
			if (((c <= 'z') && (c >= 'a')) || ((c <= 'Z') && (c >= 'A'))) {
				characters++;
				words++;
				while ((c = fgetc(fp)) != EOF) {
					if (((c <= 'z') && (c >= 'a')) || ((c <= 'Z') && (c >= 'A'))) {
						characters++;
					} else if (c == '\n') {
						sentences++;
						break;
					} else if (c == ' ') {
						break;
					} else {
						break;
					}
				}
			} else if (c == ' ') {
				words++;
			} else if (c == '\n') {
				sentences++;
			} else {
				break;
			}
		}
		cout << "字符数为:" << characters << endl;
		cout << "单词数为:" << words << endl;
		cout << "句子数为:" << sentences << endl;
		return 1;
	} else {
		cout << "open file error" << endl;
		return 0;
	}
}

int main() {
	char name[100];  //name代表文件名
	cout << "请输入：wc.exe -";
	cin >> name;
	input_m(name);
}